From: Jan Beulich Date: Wed, 7 Feb 2018 15:31:41 +0000 (+0100) Subject: x86: reduce Meltdown band-aid IPI overhead X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~614 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=a22320e32dca0918ed23799583f470afe4c24330;p=xen.git x86: reduce Meltdown band-aid IPI overhead In case we can detect single-threaded guest processes (by checking whether we can account for all root page table uses locally on the vCPU that's running), there's no point in issuing a sync IPI upon an L4 entry update, as no other vCPU of the guest will have that page table loaded. Signed-off-by: Jan Beulich Acked-by: George Dunlap Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 531c0b49b9..35f204369b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3706,8 +3706,18 @@ long do_mmu_update( break; rc = mod_l4_entry(va, l4e_from_intpte(req.val), mfn, cmd == MMU_PT_UPDATE_PRESERVE_AD, v); - if ( !rc ) - sync_guest = this_cpu(root_pgt); + /* + * No need to sync if all uses of the page can be accounted + * to the page lock we hold, its pinned status, and uses on + * this (v)CPU. + */ + if ( !rc && this_cpu(root_pgt) && + ((page->u.inuse.type_info & PGT_count_mask) > + (1 + !!(page->u.inuse.type_info & PGT_pinned) + + (pagetable_get_pfn(curr->arch.guest_table) == mfn) + + (pagetable_get_pfn(curr->arch.guest_table_user) == + mfn))) ) + sync_guest = true; break; case PGT_writable_page: